import Vue from "vue";
import VueRouter from "vue-router";
// @ts-ignore
import Login from "@/views/Login/Login";
import Main from "@/views/Main/index.vue";

Vue.use(VueRouter);
// 主要路由动态加载
// const dynamicRouting = fileName => () =>import(`@/views${fileName}/index.vue`)
const routes = [
  {//登陆
    path: "/",
    name: "Login",
    component: Login,
    meta:{
      title:'曲谱'
    }
  },
  {
    path: "/main",
    name: "Main",
    component:Main,
    meta:{
      title:'首页'
    }
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

//页面标题替换
router.beforeEach((to,from,next) => {
  if(to.meta.title){
    document.title = to.meta.title
  }
  next()
})
export default router;
